package module.service.impl;

import common.bean.SearchPageResult;
import common.bean.SearchParameter;
import module.dao.EvaluationFormDao;
import module.model.EvaluationFormModel;
import module.model.ServiceModel;
import module.service.EvaluationFormService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

/**
 * 评估表单
 */
@Service
public class EvaluationFormServiceImpl implements EvaluationFormService {
    @Autowired
    private EvaluationFormDao evaluationFormDao;
    @Transactional
    public EvaluationFormModel saveEvaluationFormModel(EvaluationFormModel evaluationFormModel) {
        if(evaluationFormModel.getFormId()==null){
            evaluationFormModel.setCreateDate(new Date());
            evaluationFormDao.save(evaluationFormModel);
        }else{
            evaluationFormModel.setLastUpdateTime(new Date());
            evaluationFormDao.update(evaluationFormModel);
        }
        return evaluationFormModel;
    }
    @Transactional
    public List<EvaluationFormModel> getEvaluationFormModelListBySearchParameter(SearchParameter searchParameter) {
        return evaluationFormDao.getEvaluationFormModelListBySearchParameter(searchParameter);
    }
    @Transactional
    public SearchPageResult<EvaluationFormModel> getEvaluationFormModelListPage(SearchParameter searchParameter) {
        return evaluationFormDao.getEvaluationFormModelListPage(searchParameter);
    }
    @Transactional
    public EvaluationFormModel getEvaluationFormModelByFormId(Long formId) {
        return evaluationFormDao.load(EvaluationFormModel.class,formId);
    }
}
